home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / reuse.lha / reuse / m2c / Times.c < prev    next >
C/C++ Source or Header  |  1992-08-18  |  1KB  |  77 lines

  1. #include "SYSTEM_.h"
  2.  
  3. #ifndef DEFINITION_System
  4. #include "System.h"
  5. #endif
  6.  
  7. #ifndef DEFINITION_IO
  8. #include "IO.h"
  9. #endif
  10.  
  11. #ifndef DEFINITION_Times
  12. #include "Times.h"
  13. #endif
  14.  
  15.  
  16. static LONGINT PrevTime;
  17.  
  18.  
  19. LONGINT Times_CpuTime
  20. # ifdef __STDC__
  21. ()
  22. # else
  23. ()
  24. # endif
  25. {
  26.   return Time();
  27. }
  28.  
  29. LONGINT Times_StepTime
  30. # ifdef __STDC__
  31. ()
  32. # else
  33. ()
  34. # endif
  35. {
  36.   LONGINT ActTime;
  37.   LONGINT DeltaTime;
  38.  
  39.   ActTime = Times_CpuTime();
  40.   DeltaTime = ActTime - PrevTime;
  41.   PrevTime = ActTime;
  42.   return DeltaTime;
  43. }
  44.  
  45. void Times_WriteStepTime
  46. # ifdef __STDC__
  47. (CHAR Text[], LONGCARD O_1)
  48. # else
  49. (Text, O_1)
  50. CHAR Text[];
  51. LONGCARD O_1;
  52. # endif
  53. {
  54.   OPEN_ARRAY_LOCALS
  55.  
  56.   ALLOC_OPEN_ARRAYS(O_1 * sizeof(CHAR), 1)
  57.   COPY_OPEN_ARRAY(Text, O_1, CHAR)
  58.   IO_WriteS((System_tFile)IO_StdOutput, Text, O_1);
  59.   IO_WriteI((System_tFile)IO_StdOutput, Times_StepTime(), 5L);
  60.   IO_WriteNl((System_tFile)IO_StdOutput);
  61.   FREE_OPEN_ARRAYS
  62. }
  63.  
  64. void BEGIN_Times()
  65. {
  66.   static BOOLEAN has_been_called = FALSE;
  67.  
  68.   if (!has_been_called) {
  69.     has_been_called = TRUE;
  70.  
  71.     BEGIN_System();
  72.     BEGIN_IO();
  73.  
  74.     PrevTime = 0;
  75.   }
  76. }
  77.